<?php
class TipoMarker extends Doctrine_Record {
    public function setTableDefinition() {
        $this->setTableName('tipomarker');
        $this->hasColumn('contenido','string',50);
    }

    public static function reciclador () {
        return Doctrine::getTable('tipoMarker')->findOneByContenido('reciclador');
    }
    public static function acopiador () {
        return Doctrine::getTable('tipoMarker')->findOneByContenido('acopiador');
    }
    public static function cooperativa () {
        return Doctrine::getTable('tipoMarker')->findOneByContenido('cooperativa');
    }
    public static function particular () {
        return Doctrine::getTable('tipoMarker')->findOneByContenido('particular');
    }
    public static function municipal () {
        return Doctrine::getTable('tipoMarker')->findOneByContenido('municipal');
    }
    public static function domestico () {
        return Doctrine::getTable('tipoMarker')->findOneByContenido('domestico');
    }

    public static function toSelect ($objeto=false) {
        $html = '<select id="selectTipoMarker" name="tipoMarker" class="form-dropdown">';
        $tipoMarkers = Doctrine::getTable('tipoMarker')->findAll();
        foreach ($tipoMarkers as $tipoMarker) {
            $selected = ($objeto && $objeto->tipo->id == $tipoMarker->id)?' selected="selected"':'';
            $html .= '<option value="'.$tipoMarker->id.'" '.$selected.'>'.$tipoMarker->contenido.'</option>';
        }
        $html .= '</select>';
        return $html;
    }
}
?>